'\" t
.\"
.\" Copyright (c) 2013-2015,2018-2019,2021-2023 Red Hat.
.\" Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMPROXY 1 "PCP" "Performance Co-Pilot"
.SH NAME
\f3pmproxy\f1 \- proxy for performance metrics collector and querying
.SH SYNOPSIS
\f3pmproxy\f1
[\f3\-AdfFt?\f1]
[\f3\-c\f1 \f2conffile\f1]
[\f3\-D\f1 \f2debug\f1]
[\f3\-h\f1 \f2host\f1[,\f2host\f1 ...]
[\f3\-i\f1 \f2ipaddress\f1]
[\f3\-l\f1 \f2logfile\f1]
[\f3\-L\f1 \f2bytes\f1]
[\f3\-p\f1 \f2port\f1[,\f2port\f1 ...]
[\f3\-r\f1 \f2port\f1[,\f2port\f1 ...]
[\f3\-s\f1 \f2sockname\f1]
[\f3\-U\f1 \f2username\f1]
[\f3\-x\f1 \f2outfile\f1]
.SH DESCRIPTION
.B pmproxy
acts as a protocol proxy,
allowing Performance Co-Pilot (PCP) monitoring clients to connect to
one or more
.BR pmcd (1)
and/or key-value servers (such as \c
.BR https://valkey.io/ )
indirectly.
.PP
In its default mode of operation
.B pmproxy
provides the REST API for PCP services (see
.BR PMWEBAPI (3)
for details).
This includes provision of an Open Metrics -
.I https://openmetrics.io
- text interface for PCP metrics at
.IR /metrics ,
real-time access to PCP metrics through the
.I /pmapi
interfaces,
and access to the fast, scalable PCP time series query
capabilities offered in conjunction with a key-value
server (see
.BR pmseries (1)
for details) via the
.I /query
REST interfaces.
.PP
.B pmproxy
can be deployed in a firewall domain, or on a cluster ``head'' node
where the IP (Internet Protocol) address of the hosts where
.B pmcd
and/or a key-value server (such as
.BR https://valkey.io/ )
are running may be unknown to the PCP monitoring clients, but where
the IP address of the host running
.B pmproxy
is known to these clients.
Similarly, the clients may have network connectivity only to the
host where
.B pmproxy
is running, while there is network connectivity from that host to the
hosts of interest where
.B pmcd
and/or a key-value server are running.
.PP
The behaviour of the PCP monitoring clients is controlled by either the
.B PMPROXY_HOST
environment variable or through the extended hostname specification
(see
.BR PCPIntro (1)
for details).
If neither of these mechanisms is used, clients will make their
.BR PMAPI (3)
connections directly to
.BR pmcd .
If the proxy hostname syntax is used or
.B PMPROXY_HOST
is set, then this should be the hostname or IP address of the system
where
.B pmproxy
is running, and the clients will connect to
.B pmcd
or a key-value server indirectly through the protocol proxy services of
.BR pmproxy.
.SH OPTIONS
The available command line options are:
.TP 5
.B \-A
Disable service advertisement.
By default,
.B pmproxy
will advertise its presence on the network using any available mechanisms
(such as Avahi/DNS-SD), assisting remote monitoring tools with finding it.
These mechanisms are disabled with this option.
.TP
\f3\-c\f1 \f2conffile\f1, \f3\-\-config\f1=\f2conffile\f1
Specify the path to an optional configuration
.IR conffile ,
with format as described in the ``CONFIGURATION'' section.
This option implies \f3pmproxy\f1 is running in \f3timeseries\f1 mode.
.TP
\f3\-d\f1, \f3\-\-deprecated\f1
By default
.B pmproxy
prefers to run in the new \f3timeseries\f1 mode, providing REST APIs,
asynchronous network I/O, scalable time series, and secure connections
using OpenSSL.
However, legacy deployments may wish to use the original synchronous
.B pmproxy
implementation using libpcp networking; this can be achieved using
this option.
Note that the \f3\-d\f1 and \f3\-t\f1 options are mutually exclusive.
.TP
\f3\-f\f1, \f3\-\-foreground\f1
By default
.B pmproxy
is started as a daemon.
The
.B \-f
option indicates that it should run in the foreground.
This is most useful when trying to diagnose problems with establishing
connections.
.TP
\f3\-F\f1, \f3\-\-systemd\f1
Like
.BR \-f ,
the
.B \-F
option runs
.B pmproxy
in the foreground, but also does some housekeeping (like create a
``pid'' file and change user id).  This is intended for use when
.B pmproxy
is launched from
.BR systemd (1)
and the daemonising has already been done by
.BR systemd (1)
and does not need to be done again by
.BR pmproxy ,
which is the case when neither
.B \-f
nor
.B \-F
is specified.
.RS +5n
.PP
At most one of
.B \-f
and
.B \-F
may be specified.
.RE
.TP
\f3\-h\f1 \f2host\f1, \f3\-\-keyhost\f1=\f2host\f1
Specify an alternate key-value server
.I host
to connect to for time series querying, overriding any configuration
file settings.
This option implies \f3pmproxy\f1 is running in \f3timeseries\f1 mode.
.TP
\f3\-i\f1 \f2ipaddress\f1, \f3\-\-interface\f1=\f2ipaddress\f1
This option is usually only used on hosts with more than one network
interface (very common for firewall and ``head'' node hosts where
.B pmproxy
is likely to be deployed to arbitrate access to an internal network).
If no
.B \-i
options are specified
.B pmproxy
accepts PCP client connections on any of its host's IP addresses.
The
.B \-i
option is used to specify explicitly an IP address that PCP client connections should be
accepted on.
.I ipaddress
should be in the standard dotted form (e.g. 100.23.45.6).
The
.B \-i
option may be used multiple times to define a list of IP addresses.
When one or more
.B \-i
options is specified, attempted connections made on any other IP addresses will be refused.
.TP
\f3\-l\f1 \f2logfile\f1, \f3\-\-log\f1=\f2logfile\f1
By default a log file named
.I pmproxy.log
is written in the current directory.
The
.B \-l
option causes the log file to be written to a given
.I logfile
instead of the default.
If this
.I logfile
cannot be created or is not writable, output is
written to the standard error instead.
.TP
\f3\-L\f1 \f2bytes\f1
.IR PDU s
received by
.B pmproxy
from PCP monitoring clients are restricted to a
maximum size of 65536 bytes by default to defend against Denial of
Service attacks.
The
.B \-L
option may be used to change the maximum incoming
.I PDU
size.
.TP
\f3\-p\f1 \f2port\f1, \f3\-\-port\f1=\f2port\f1
Specify an alternate
.I port
number to listen on for client connections.
The default value is 44322.
.TP
\f3\-r\f1 \f2port\f1, \f3\-\-keyport\f1=\f2port\f1
Specify an alternate key-value server
.I port
number to connect to for time series querying, overriding any
configuration file settings.
This option implies \f3pmproxy\f1 is running in \f3timeseries\f1 mode.
.TP
\f3\-s\f1 \f2sockname\f1, \f3\-\-socket\f1=\f2sockname\f1
Specify the path to a local unix domain socket (for platforms supporting this
socket family only).
The default value is
.IR $PCP_RUN_DIR/pmproxy.socket .
This option implies \f3pmproxy\f1 is running in \f3timeseries\f1 mode.
.TP
\fB\-t\f1, \fB\-\-timeseries\f1
Operate in automatic archive timeseries discovery mode.
This mode of operation will enable the
.BR PMWEBAPI (3)
REST APIs, dynamically and automatically detect active system
archives being written by
.BR pmlogger (1)
and import them into a key-value server (such as
.BR https://valkey.io/ ),
for fast, scalable time series querying described in
.BR pmseries (1).
Note that in this mode of operation,
.B pmproxy
only "log-tails" and ingests actively growing archives, e.g. as written by one or more
.BR pmlogger (1)
instances.
When an archive is first discovered (usually but not limited to
.B pmproxy
startup),
all metadata is loaded and sent to the configured key-value server
however note that only
.B new
archive metric value data from the tail end of each archive is ingested.
Compressed archives never grow and so are ignored.
See the
.B \-\-load
option to
.BR pmseries (1)
for a supported mechanism for manually loading all of the metric value data
from previously collected (inactive) archives,
whether compressed or not.
It would be normal, though not mandated, for a set of archives being manually loaded
to cover the same time period, e.g. archive data for a particular week for one or more
hosts in the same data-centre.
.TP
\f3\-U\f1 \f2username\f1, \f3\-\-username\f1=\f2username\f1
Assume the identity of the given
.I username
before starting to accept incoming packets from PCP monitoring clients.
.TP
\f3\-x\f1 \f2outfile\f1
Before the
.B pmproxy
.I logfile
can be opened,
.B pmproxy
may encounter a fatal error which prevents it from starting.
By default the output describing this error is sent to
.B /dev/tty
but it may redirected to
.IR outfile .
.TP
\fB\-?\fR, \fB\-\-help\fR
Display usage message and exit.
.SH CONFIGURATION
When running in the \f3timeseries\f1 mode of operation, runtime
configuration is relatively complex and typically handled via the
.I $PCP_SYSCONF_DIR/pmproxy/pmproxy.conf
file.
This file is in the common ``ini'' format, with section headers
and individual variables and values with each section.
The configuration file installed as part of PCP documents
every available section and option.
.PP
At a high level, the
.I [pmproxy]
section can be used to explicitly enable or disable each of the
different protocols.
.PP
The
.I [http]
section provides fine-tuning over HTTP server settings used by
.BR pmproxy.
.I chunksize
sets the chunked transfer encoding buffer size, and defaults to
the system pagesize.
Access control HTTP protocol settings can be adjusted using the
.I Access-Control-Allow-Headers
and
.I Access-Control-Max-Age
options.
Discussion of these HTTP protocol headers is beyond the scope of
this document, but suitable default values are described within
the
.I pmproxy.conf
configuration file.
.PP
The
.I [keys]
section allows connection information for one or more backing
key-value server processes to be configured (hostnames and ports).
Note to access multiple (scalable) key-value servers, the
.I servers
variable in this section can be a comma-separated list of
hostname:port pairs.
Alternatively, it can be a single key-value server host
that will be queried using the "CLUSTER INFO" command to
automatically configure multiple backing hosts.
.PP
In earlier versions of PCP (before 6) an alternative configuration
setting section was used for this purpose \- key-value
.I servers
were specified in the
.I [pmseries]
section and this is still accepted as a fallback for backwards
compatibility.
.SH STARTING AND STOPPING PMPROXY
Normally,
.B pmproxy
is started automatically at boot time and stopped when the
system is being brought down.
Under certain circumstances it is necessary to start or stop
.B pmproxy
manually.
To do this one must become superuser and type
.PP
.ft CR
# $PCP_RC_DIR/pmproxy start
.ft 1
.PP
to start
.BR pmproxy ,
or
.PP
.ft CR
# $PCP_RC_DIR/pmproxy stop
.ft 1
.PP
to stop
.BR pmproxy .
Starting
.B pmproxy
when it is already running is the same as stopping
it and then starting it again.
.P
Normally
.B pmproxy
listens for PCP client connections on TCP/IP port number 44322
(as well as 44323 with \f3timeseries\f1 enabled) registered at
.BR https://www.iana.org/ .
Either the environment
variable
.B PMPROXY_PORT
or the
.B \-p
command line option may be used to specify alternative port
number(s) when
.B pmproxy
is started; in each case, the specification is a comma-separated list
of one or more numerical port numbers.
Should both methods be used or multiple
.B \-p
options appear on the command line,
.B pmproxy
will listen on the union of the set of ports specified via all
.B \-p
options and the
.B PMPROXY_PORT
environment variable.
If non-default ports are used with
.B pmproxy
care should be taken to ensure that
.B PMPROXY_PORT
is also set in the environment of any client application that
will connect to
.BR pmproxy ,
or that the extended host specification syntax is used
(see
.BR PCPIntro (1)
for details).
.SH DIAGNOSTICS
If
.B pmproxy
is already running the message "Error: OpenRequestSocket bind: Address already
in use" will appear.
This may also appear if
.B pmproxy
was shutdown with an outstanding request from a client.
In this case, a
request socket has been left in the TIME_WAIT state and until the system closes
it down (after some timeout period) it will not be possible to run
.BR pmproxy .
.PP
In addition to the standard
.B PCP
debugging options, see
.BR pmdbg (1),
.B pmproxy
currently supports the debugging option
.B context
for tracing client connections and disconnections.
.SH FILES
.TP 5
.I $PCP_PMPROXYOPTIONS_PATH
command line options for
.B pmproxy
when launched from
.B $PCP_RC_DIR/pmproxy
All the command line option lines should start with a hyphen as
the first character.
.TP
.I $PCP_SYSCONFIG_DIR/pmproxy
Environment variables that will be set when
.B pmproxy
executes.
Only settings of the form "PMPROXY_VARIABLE=value" will be honoured.
.TP
.I \&./pmproxy.log
(or
.B $PCP_LOG_DIR/pmproxy/pmproxy.log
when started automatically)
.br
All messages and diagnostics are directed here
.TP
.I /etc/pki/tls
default OpenSSL certificate database directory, optionally used for
Secure Socket Layer connection in \f3timeseries\f1 mode of operation.
These certificates can be created and queried using the
.B openssl
tool, amongst others.
.SH ENVIRONMENT
In addition to the PCP environment variables described in the
.B "PCP ENVIRONMENT"
section below, there are several environment variables that
influence the interactions between a PCP monitoring client,
.B pmproxy
and
.BR pmcd .
.TP
.B PMCD_PORT
For the PCP monitoring client this (or the default port number) is passed to
.B pmproxy
and used to connect to
.BR pmcd .
In the environment of
.B pmproxy
.B PMCD_PORT is not used.
.TP
.B PMPROXY_HOST
For the PCP monitoring client this is the hostname or IP address of the
host where
.B pmproxy
is running.
In recent versions of PCP (since version 3) this has been superseded by
the extended hostname syntax
(see
.BR PCPIntro (1)
for details).
.TP
.B PMPROXY_PORT
For the PCP monitoring client this is the port on which
.B pmproxy
will accept connections.
The default is 44322, as well as 44323 with \f3timeseries\f1 enabled.
.TP
.BR PMCD_CONNECT_TIMEOUT ", " PMCD_RECONNECT_TIMEOUT " and " PMCD_REQUEST_TIMEOUT
(see
.BR PCPIntro (1))
For the PCP monitoring client, setting these environment variables
will modify the timeouts used for interactions between the client
and
.BR pmproxy
(independent of which
.B pmcd
is being used).
For
.B pmproxy
these same environment variables control the timeouts between
.B pmproxy
and all
.BR pmcd (1)
instances (independent of which monitoring client is involved).
.PP
If set to the value 1, the
.B PMPROXY_LOCAL
environment variable will cause
.B pmproxy
to run in a localhost-only mode of operation, where it binds only
to the loopback interface.
.PP
The
.B PMPROXY_MAXPENDING
variable can be set to indicate the maximum length to which the queue
of pending client connections may grow.
.SH PCP ENVIRONMENT
Environment variables with the prefix \fBPCP_\fP are used to parameterize
the file and directory names used by PCP.
On each installation, the
file \fI/etc/pcp.conf\fP contains the local values for these variables.
The \fB$PCP_CONF\fP variable may be used to specify an alternative
configuration file, as described in \fBpcp.conf\fP(5).
.PP
For environment variables affecting PCP tools, see \fBpmGetOptions\fP(3).
.SH DEBUGGING OPTIONS
The
.B \-D
or
.B \-\-debug
option enables the output of additional diagnostics on
.I stderr
to help triage problems, although the information is sometimes cryptic and
primarily intended to provide guidance for developers rather end-users.
.I debug
is a comma separated list of debugging options; use
.BR pmdbg (1)
with the
.B \-l
option to obtain
a list of the available debugging options and their meaning.
.PP
Debugging options specific to
.B pmproxy
are as follows:
.TS
box;
lf(B) | lf(B)
lf(B) | lxf(R) .
Option	Description
_
appl0	client connections and disconnections
_
appl1	T{
desperate logging mode, where a period followed by the PID of
\fBpmproxy\fR is inserted in the name of \fIRlogfile\fP before the last
period, so for example pmproxy.log becomes pmproxy.<pid>.log
T}
_
appl2	T{
log incoming HTTP URLs (this is also enabled by the \fBhttp\fR debugging
option, but the latter has broader scope because it turns on debugging
in the libraries that \fBpmproxy\fR uses)
T}
.TE
.SH SEE ALSO
.BR PCPIntro (1),
.BR pmcd (1),
.BR pmdbg (1),
.BR pmlogger (1),
.BR pmseries (1),
.BR PMAPI (3),
.BR PMWEBAPI (3),
.BR pmGetOptions (3),
.BR pcp.conf (5)
and
.BR pcp.env (5).

.\" control lines for scripts/man-spell
.\" +ok+ Avahi OpenRequestSocket OpenSSL
.\" +ok+ PMPROXY PMPROXY_VARIABLE
.\" +ok+ SD {from DNS-SD} TIME_WAIT
.\" +ok+ openssl pki valkey
